﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Rotempco.BaseClass.Objects.Enums;
using Rotempco.BaseClass.Objects.ReturnObjects;
using Rotempco.BaseClass;
using Rotempco.Website.Objects;
using Rotempco.Core.ORM.Objects.Stores;
using Rotempco.Core.Logic;

namespace Rotempco.Website.Logic
{
    public class AutoLoginLogic
    {
        public static void Login()
        {
            PublicSessionStore.Instance.Clear();

            LoginResult loginResult = Factory.LoginUser.Login("test@test.dk", "123");
            if (loginResult.LoginResultEnum != LoginResultEnum.Success)
                throw new Exception("Login failure");

            SessionStore.Instance.LoginUser = loginResult.LoginUser;
            SessionStore.Instance.PrivateEncryptionKey = CoreSettingsLogic.GetPrivateDecryptionKey();
        }

        public static void Logout()
        {
            SessionStore.Instance.Clear();
            CoreSettingsLogic.SetPrivateDecryptionKey(null);
            PublicSessionStore.Instance.Clear();
        }

    }
}